package com.ruicar.afs.cloud.basic.common.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.ruicar.afs.cloud.common.core.entity.BaseEntity;
import com.ruicar.afs.cloud.common.modules.contract.enums.ProcessStatusEnum;
import com.ruicar.afs.cloud.common.modules.contract.enums.ReceiptSourceTypeEnum;
import com.ruicar.afs.cloud.common.modules.contract.enums.TreatmentMethodEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;

/**
 * @author infinity
 * @version 1.0
 * @date 2020/9/3 11:42
 */
@Data
@TableName(value ="basic_revoke_handle", autoResultMap = true)
public class BasicRevokeHandle extends BaseEntity {
    @ApiModelProperty("收据id")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long receiptId;
    @ApiModelProperty("案件编号")
    private String caseNo;
    @ApiModelProperty("客户编号")
    private String custNo;
    @ApiModelProperty("收款来源类型 枚举值：对公结算，微信还款，银行代扣")
    private ReceiptSourceTypeEnum sourceType;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty("案件发起时间")
    private Date startTime;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty("案件结束时间")
    private Date endTime;
    @ApiModelProperty("合同号")
    private String contractNo;
    @ApiModelProperty("处理方式")
    private TreatmentMethodEnum treatmentMethod;
    @ApiModelProperty("案件编号")
    private String handleCaseNo;
    @ApiModelProperty("处理状态")
    private ProcessStatusEnum processStatus ;
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty("收款成功时间")
    private Date succeedTime;
    @ApiModelProperty("收款金额 不可为负数")
    private BigDecimal arriveAmt;
    public static BasicRevokeHandle convertFromDto(BasicReceiptRecord basicReceiptRecord) {
        BasicRevokeHandle basicRevokeHandle = new BasicRevokeHandle();
        basicRevokeHandle.setReceiptId(basicReceiptRecord.getId());
        basicRevokeHandle.setProcessStatus(ProcessStatusEnum.draft);
        basicRevokeHandle.setContractNo(basicReceiptRecord.getContractNo());
        basicRevokeHandle.setSourceType(basicReceiptRecord.getSourceType());
        basicRevokeHandle.setSucceedTime(basicReceiptRecord.getSucceedTime());
        basicRevokeHandle.setArriveAmt(basicReceiptRecord.getArriveAmt());
        basicRevokeHandle.setCustNo(basicReceiptRecord.getCustNo());
        return basicRevokeHandle;
    }
}
